<template>
    <div class="info-header">
      <div class="content">
        <el-menu :default-active="activeIndex"
                 class="el-menu-demo"
                 mode="horizontal"
                 ref="index_menu"
                 @select="handleSelect"
                 active-text-color="#409eff">
          <!-- 导航菜单 -->
          <el-menu-item index="0" @click="()=>this.$router.push('/')">首页</el-menu-item>
          <!-- 导航菜单树组件，动态加载菜单 -->
          <menu-tree v-for="menu in category" :key="menu.categoryId" :menu="menu"></menu-tree>
        </el-menu>
      </div>
    </div>
</template>

<script>
import MenuTree from '../../Component/MenuTree/Index'
import { mapState } from 'vuex'
export default {
    components: { MenuTree },
    name: 'HeadBar',
    component: {
        MenuTree
    },
    watch: {
        $route: 'handleRoute'
    },
    data() {
        return {
        }
    },
    computed: {
        ...mapState({
            category: state => state.index.category,
            activeIndex: state => state.index.activeIndex
        })
    },
    methods: {
        handleSelect(key, keyPath) {
            // console.log(keyPath)
        },
        handleRoute(route) {
            // console.log(route)
        }
    },
    mounted() {
        console.log(this.$refs.index_menu)
    }
}
</script>

<style scoped>
  .info-header{
    height: 80px;
    line-height: 80px;
    text-align: center;
  }
</style>
